import request from '@/utils/axios'

export type NotifyTemplateType = {
  id: number
  name: string
  nickname: string
  code: string
  content: string
  type?: number
  params: string
  status: number
  remark: string
}

export interface NotifyTemplatePageReqType extends PageParam {
  name?: string
  code?: string
  status?: number
  create_time?: Date[]
}

export interface NotifySendReqType {
  userId: number
  userType: number
  templateCode: string
  templateParams: Map<string, object>
}

/**
 * 消息中心 - 站内信管理 - 站内信模板接口
 */
export const NotifyTemplateApi = {
  // 新增
  create: (data: NotifyTemplateType) => {
    return request.post({ url: '/system/notify-template/create', data, is_mock: true })
  },
  // 修改
  update: (data: NotifyTemplateType) => {
    return request.put({ url: '/system/notify-template/update', data, is_mock: true })
  },
  // 删除
  delete: (id: number) => {
    return request.delete({ url: '/system/notify-template/delete?id=' + id, is_mock: true })
  },
  // 查询详情
  detail: (id: number) => {
    return request.get({ url: '/system/notify-template/detail?id=' + id, is_mock: true })
  },
  // 查询分页列表
  page: (params: NotifyTemplatePageReqType) => {
    return request.get({ url: '/system/notify-template/page', params, is_mock: true })
  },
  // 发送站内信
  send: (data: NotifySendReqType) => {
    return request.post({ url: '/system/notify-template/send-notify', data, is_mock: true })
  }
}
